package com.asen.commons.core.generator.factory;

import com.asen.commons.core.generator.impl.SnowflakeIdGenerator;

/**
 * ID生成器工厂
 *
 * @author Gary
 * @version 1.0
 * @date 2018-11-17
 */
public class IdGeneratorFactory {

    private static SnowflakeIdGenerator snowflakeIdGenerator = null;

    public static SnowflakeIdGenerator getSnowflakeIdGenerator() {
        if (snowflakeIdGenerator == null) {
            synchronized (SnowflakeIdGenerator.class) {
                // TODO 机器码参数从配置文件中获取
                if (snowflakeIdGenerator == null) {
                    snowflakeIdGenerator = new SnowflakeIdGenerator(0, 0);
                }
            }
        }

        return snowflakeIdGenerator;
    }
}
